﻿// widget.h
#ifndef WIDGET_H
#define WIDGET_H

#include <QWidget>
#include <QSerialPort>
#include <QLabel>
#include <QCamera>
#include <QImageCapture>

QT_BEGIN_NAMESPACE
namespace Ui {
class Widget;
}
QT_END_NAMESPACE

class Widget : public QWidget
{
    Q_OBJECT

public:
    Widget(QWidget *parent = nullptr);
    ~Widget();

protected:
    void resizeEvent(QResizeEvent *event) override;

private slots:
    void sendCommand(const QString &cmd, const QString &action);
    void readyForCapture(bool ready);
    void processCapturedImage(int id, const QImage& preview);
    void displayCameraError(QCamera::Error error);

private:
    Ui::Widget *ui;
    QSerialPort *serial;
    QLabel *statusLabel;
    QLabel *faceLabel;
    QString buttonStyle();
    void initCamera();
    QCamera *camera = nullptr;
    QImageCapture *imageCapture = nullptr;
};

#endif // WIDGET_H
